#ifndef __MAP_H__
#define __MAP_H__

#include <vector>
#include "MapTile.h"
#include "Maze.h"
#include <boost/smart_ptr/shared_ptr.hpp>



#include "Entity.h"




class CMap : public IEntity
{
public:
	CMap();
	virtual ~CMap();
	virtual void render();
	virtual void update();
	virtual void load(const char *szFileName) {}

	void init(unsigned int uiNbTileX, unsigned int uiNbTileY);
	void load(const MazePtr& pContent);

	inline void setTileType(unsigned int uiX, unsigned int uiY, CMapTile::eType type)
	{
		const unsigned int uiOffset = uiY * m_uiNbTilesX + uiX;

		if (uiOffset < m_pTiles.size())
			m_pTiles[uiOffset]->setType(type);
	}

	inline CMapTile::eType getTileType(unsigned int uiX, unsigned int uiY)
	{
		const unsigned int uiOffset = uiY * m_uiNbTilesX + uiX;

		if (uiOffset < m_pTiles.size())
			return m_pTiles[uiOffset]->getType();
		return CMapTile::nothing;
	}

private:
	std::vector<MapTilePtr> m_pTiles;
	unsigned int		m_uiNbTilesX;
	unsigned int		m_uiNbTilesY;

	void resetMap();
};

typedef boost::shared_ptr<CMap> MapPtr;



#endif // __MAP_H__